/*
 * @Author: liuxinyea
 * @Date: 2024-08-11 00:26:43
 * @LastEditors: liuxinyea
 * @LastEditTime: 2024-08-19 22:07:27
 * @Description: 植物基类
 */
import { _decorator, animation, Animation, BoxCollider2D, CCInteger, Component, Enum, Node } from 'cc';
import { PlantState, PlantType } from './Glabol';
const { ccclass, property } = _decorator;

@ccclass('Plant')
export class Plant extends Component {
    private mPlantState:PlantState = PlantState.Disable;
    @property({ type: Enum(PlantType) })
    public plantType: PlantType
    @property(CCInteger)
    public healthNum: number
    start() {
       this.transitionDisable()
    }

    update(deltaTime: number) {
        switch (this.mPlantState) {
            case PlantState.Disable:
                this.disableUpdate()
                break;
            case PlantState.Enabel:
                this.enableUpdate()
                break;
        
            default:
                break;
        }
    }
    // 未激活状态更新逻辑
    disableUpdate(){

    }
    // 种下去之后再激活
    enableUpdate(){
        
    }
    transitionDisable(){
        this.mPlantState = PlantState.Disable
        const mAnimation = this.getComponent(animation.AnimationController)
        mAnimation.enabled = false 
    }
    transitionEnable(){
        this.mPlantState = PlantState.Enabel
        const mAnimation = this.getComponent(animation.AnimationController)
        mAnimation.enabled = true 
    }
}